<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>TurtleDB: src/ca/uqac/dim/turtledb/XmlQueryParser.java Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">TurtleDB
   
   </div>
   <div id="projectbrief">A mini distributed database system</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Packages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_xml_query_parser_8java.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">src/ca/uqac/dim/turtledb/XmlQueryParser.java</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_xml_query_parser_8java.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*-------------------------------------------------------------------------</span>
<a name="l00002"></a>00002 <span class="comment">    Simple distributed database engine</span>
<a name="l00003"></a>00003 <span class="comment">    Copyright (C) 2012  Sylvain Hallé</span>
<a name="l00004"></a>00004 <span class="comment"></span>
<a name="l00005"></a>00005 <span class="comment">    This program is free software: you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment">    it under the terms of the GNU General Public License as published by</span>
<a name="l00007"></a>00007 <span class="comment">    the Free Software Foundation, either version 3 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment">    (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment"></span>
<a name="l00010"></a>00010 <span class="comment">    This program is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00013"></a>00013 <span class="comment">    GNU General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment"></span>
<a name="l00015"></a>00015 <span class="comment">    You should have received a copy of the GNU General Public License</span>
<a name="l00016"></a>00016 <span class="comment">    along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<a name="l00017"></a>00017 <span class="comment"> -------------------------------------------------------------------------*/</span>
<a name="l00018"></a>00018 <span class="keyword">package </span>ca.uqac.dim.turtledb;
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="keyword">import</span> java.io.*;
<a name="l00021"></a>00021 <span class="keyword">import</span> java.util.*;
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="keyword">import</span> javax.xml.parsers.*;
<a name="l00024"></a>00024 <span class="keyword">import</span> org.w3c.dom.*;
<a name="l00025"></a>00025 <span class="keyword">import</span> org.xml.sax.InputSource;
<a name="l00026"></a>00026 <span class="keyword">import</span> org.xml.sax.SAXException;
<a name="l00027"></a>00027 
<a name="l00038"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">00038</a> <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>
<a name="l00039"></a>00039 {
<a name="l00045"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af45aba32674228c6538d7055ea6e0c6d">00045</a>   <span class="keyword">public</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af45aba32674228c6538d7055ea6e0c6d">parse</a>(String s) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00046"></a>00046   {
<a name="l00047"></a>00047     DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
<a name="l00048"></a>00048     DocumentBuilder builder = null;
<a name="l00049"></a>00049     <span class="keywordflow">try</span>
<a name="l00050"></a>00050     {
<a name="l00051"></a>00051       builder = builderFactory.newDocumentBuilder();
<a name="l00052"></a>00052     }
<a name="l00053"></a>00053     <span class="keywordflow">catch</span> (ParserConfigurationException e)
<a name="l00054"></a>00054     {
<a name="l00055"></a>00055       e.printStackTrace();  
<a name="l00056"></a>00056     }
<a name="l00057"></a>00057     <span class="keywordflow">try</span>
<a name="l00058"></a>00058     {
<a name="l00059"></a>00059       Document document = builder.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af45aba32674228c6538d7055ea6e0c6d">parse</a>(<span class="keyword">new</span> InputSource(<span class="keyword">new</span> StringReader(s)));
<a name="l00060"></a>00060       <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af45aba32674228c6538d7055ea6e0c6d">parse</a>(document);
<a name="l00061"></a>00061     }
<a name="l00062"></a>00062     <span class="keywordflow">catch</span> (SAXException e)
<a name="l00063"></a>00063     {
<a name="l00064"></a>00064       e.printStackTrace();
<a name="l00065"></a>00065     }
<a name="l00066"></a>00066     <span class="keywordflow">catch</span> (IOException e)
<a name="l00067"></a>00067     {
<a name="l00068"></a>00068       e.printStackTrace();
<a name="l00069"></a>00069     }
<a name="l00070"></a>00070     <span class="keywordflow">return</span> null;
<a name="l00071"></a>00071   }
<a name="l00072"></a>00072   
<a name="l00078"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#abf6448147479980409aad1b03973f16c">00078</a>   <span class="keyword">public</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af45aba32674228c6538d7055ea6e0c6d">parse</a>(Document doc) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00079"></a>00079   {
<a name="l00080"></a>00080     <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af45aba32674228c6538d7055ea6e0c6d">parse</a>(doc.getDocumentElement());
<a name="l00081"></a>00081   }
<a name="l00082"></a>00082   
<a name="l00095"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#ad1bd2c4f2ebf56f03a79d64b5c0bcea6">00095</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af45aba32674228c6538d7055ea6e0c6d">parse</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00096"></a>00096   {
<a name="l00097"></a>00097     NodeList nl = e.getChildNodes();
<a name="l00098"></a>00098     String name = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00099"></a>00099     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00100"></a>00100     {
<a name="l00101"></a>00101       Node n = nl.item(i);
<a name="l00102"></a>00102       <span class="keywordflow">if</span> (n.getNodeType() != Node.ELEMENT_NODE)
<a name="l00103"></a>00103           <span class="keywordflow">continue</span>;
<a name="l00104"></a>00104       Element elem = (Element) n;
<a name="l00105"></a>00105       name = elem.getTagName();
<a name="l00106"></a>00106       <span class="keywordflow">if</span> (name == null)
<a name="l00107"></a>00107           <span class="keywordflow">continue</span>;
<a name="l00108"></a>00108       name = name.toLowerCase();
<a name="l00109"></a>00109       <span class="keywordflow">if</span> (name.compareTo(<span class="stringliteral">&quot;selection&quot;</span>) == 0)
<a name="l00110"></a>00110       {
<a name="l00111"></a>00111         <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a82432bb6e481389dc5e7ce9e7f79c0a7">parseSelection</a>(n);
<a name="l00112"></a>00112       }
<a name="l00113"></a>00113       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (name.compareTo(<span class="stringliteral">&quot;projection&quot;</span>) == 0)
<a name="l00114"></a>00114       {
<a name="l00115"></a>00115         <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af4bf6881cd08e98b8983b293b42d9338">parseProjection</a>(n);
<a name="l00116"></a>00116       }
<a name="l00117"></a>00117       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (name.compareTo(<span class="stringliteral">&quot;union&quot;</span>) == 0)
<a name="l00118"></a>00118       {
<a name="l00119"></a>00119         <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a77640ae4a49cff2d914351080ef1e826">parseUnion</a>(n);
<a name="l00120"></a>00120       }
<a name="l00121"></a>00121       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (name.compareTo(<span class="stringliteral">&quot;intersection&quot;</span>) == 0)
<a name="l00122"></a>00122       {
<a name="l00123"></a>00123         <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a45d3e3781d17c282caba0a2c4a5ecbfe">parseIntersection</a>(n);
<a name="l00124"></a>00124       }
<a name="l00125"></a>00125       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (name.compareTo(<span class="stringliteral">&quot;join&quot;</span>) == 0)
<a name="l00126"></a>00126       {
<a name="l00127"></a>00127         <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a27d80682bbafcc426244da865b0746b6">parseJoin</a>(n);
<a name="l00128"></a>00128       }
<a name="l00129"></a>00129       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (name.compareTo(<span class="stringliteral">&quot;product&quot;</span>) == 0)
<a name="l00130"></a>00130       {
<a name="l00131"></a>00131         <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a8e21a91121539f67a814efef10822db4">parseProduct</a>(n);
<a name="l00132"></a>00132       }
<a name="l00133"></a>00133       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (name.compareTo(<span class="stringliteral">&quot;vartable&quot;</span>) == 0)
<a name="l00134"></a>00134       {
<a name="l00135"></a>00135         <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a7edd33f9f801afd27ef02f1fd780ffaa">parseVariableTable</a>(n);
<a name="l00136"></a>00136       }
<a name="l00137"></a>00137       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (name.compareTo(<span class="stringliteral">&quot;table&quot;</span>) == 0)
<a name="l00138"></a>00138       {
<a name="l00139"></a>00139         <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a309204e090ef3db07832361e1d986668">parseTable</a>(n);
<a name="l00140"></a>00140       }
<a name="l00141"></a>00141     }
<a name="l00142"></a>00142     <span class="comment">// If we get here, we did not recognize any operand we know</span>
<a name="l00143"></a>00143     <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Unrecognized operand: &quot;</span> + name);
<a name="l00144"></a>00144   }
<a name="l00145"></a>00145   
<a name="l00157"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a82432bb6e481389dc5e7ce9e7f79c0a7">00157</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a82432bb6e481389dc5e7ce9e7f79c0a7">parseSelection</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00158"></a>00158   {
<a name="l00159"></a>00159     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_condition.html">Condition</a> c = null;
<a name="l00160"></a>00160     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> r = null;
<a name="l00161"></a>00161     NodeList nl = e.getChildNodes();
<a name="l00162"></a>00162     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00163"></a>00163     {
<a name="l00164"></a>00164       Node n = nl.item(i);
<a name="l00165"></a>00165       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;condition&quot;</span>) == 0)
<a name="l00166"></a>00166         c = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a9159995fce11b75b9e42bf35dbb9ac8f">parseCondition</a>(n);
<a name="l00167"></a>00167       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;operand&quot;</span>) == 0)
<a name="l00168"></a>00168       {
<a name="l00169"></a>00169         r = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af45aba32674228c6538d7055ea6e0c6d">parse</a>(n);
<a name="l00170"></a>00170       }
<a name="l00171"></a>00171     }
<a name="l00172"></a>00172     <span class="keywordflow">if</span> (c == null)
<a name="l00173"></a>00173       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Missing condition in selection&quot;</span>);
<a name="l00174"></a>00174     <span class="keywordflow">if</span> (r == null)
<a name="l00175"></a>00175       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Missing operand in selection&quot;</span>);
<a name="l00176"></a>00176     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_selection.html">Selection</a> sel = <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_selection.html">Selection</a>(c, r);
<a name="l00177"></a>00177     <span class="keywordflow">return</span> sel;
<a name="l00178"></a>00178   }
<a name="l00179"></a>00179   
<a name="l00191"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af4bf6881cd08e98b8983b293b42d9338">00191</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af4bf6881cd08e98b8983b293b42d9338">parseProjection</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00192"></a>00192   {
<a name="l00193"></a>00193     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_schema.html">Schema</a> s = null;
<a name="l00194"></a>00194     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> r = null;
<a name="l00195"></a>00195     NodeList nl = e.getChildNodes();
<a name="l00196"></a>00196     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00197"></a>00197     {
<a name="l00198"></a>00198       Node n = nl.item(i);
<a name="l00199"></a>00199       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;schema&quot;</span>) == 0)
<a name="l00200"></a>00200         s = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a7d8c7b2bd4e9d833c98231d5ec43a656">parseSchema</a>(n);
<a name="l00201"></a>00201       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;operand&quot;</span>) == 0)
<a name="l00202"></a>00202       {
<a name="l00203"></a>00203         r = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af45aba32674228c6538d7055ea6e0c6d">parse</a>(n);
<a name="l00204"></a>00204       }
<a name="l00205"></a>00205     }
<a name="l00206"></a>00206     <span class="keywordflow">if</span> (s == null)
<a name="l00207"></a>00207       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Missing schema in projection&quot;</span>);
<a name="l00208"></a>00208     <span class="keywordflow">if</span> (r == null)
<a name="l00209"></a>00209       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Missing operand in projection&quot;</span>);
<a name="l00210"></a>00210     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_projection.html">Projection</a> pro = <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_projection.html">Projection</a>(s, r);
<a name="l00211"></a>00211     <span class="keywordflow">return</span> pro;
<a name="l00212"></a>00212   }
<a name="l00213"></a>00213   
<a name="l00226"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a77640ae4a49cff2d914351080ef1e826">00226</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a77640ae4a49cff2d914351080ef1e826">parseUnion</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00227"></a>00227   {
<a name="l00228"></a>00228     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_union.html">Union</a> u = <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_union.html">Union</a>();
<a name="l00229"></a>00229     NodeList nl = e.getChildNodes();
<a name="l00230"></a>00230     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00231"></a>00231     {
<a name="l00232"></a>00232       Node n = nl.item(i);
<a name="l00233"></a>00233       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;operand&quot;</span>) == 0)
<a name="l00234"></a>00234       {
<a name="l00235"></a>00235         <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> r = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af45aba32674228c6538d7055ea6e0c6d">parse</a>(n);
<a name="l00236"></a>00236         u.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_n_ary_relation.html#ac963905a165f53a616f50d18b1635245">addOperand</a>(r);
<a name="l00237"></a>00237       }
<a name="l00238"></a>00238     }
<a name="l00239"></a>00239     <span class="keywordflow">if</span> (u.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_n_ary_relation.html#aed20a0eb0271434efde6557d9d1064f9">m_relations</a>.size() &lt; 2)
<a name="l00240"></a>00240       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Union of less than 2 relations&quot;</span>);
<a name="l00241"></a>00241     <span class="keywordflow">return</span> u;
<a name="l00242"></a>00242   }
<a name="l00243"></a>00243   
<a name="l00256"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a45d3e3781d17c282caba0a2c4a5ecbfe">00256</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a45d3e3781d17c282caba0a2c4a5ecbfe">parseIntersection</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00257"></a>00257   {
<a name="l00258"></a>00258     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_intersection.html">Intersection</a> u = <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_intersection.html">Intersection</a>();
<a name="l00259"></a>00259     NodeList nl = e.getChildNodes();
<a name="l00260"></a>00260     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00261"></a>00261     {
<a name="l00262"></a>00262       Node n = nl.item(i);
<a name="l00263"></a>00263       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;operand&quot;</span>) == 0)
<a name="l00264"></a>00264       {
<a name="l00265"></a>00265         <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> r = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af45aba32674228c6538d7055ea6e0c6d">parse</a>(n);
<a name="l00266"></a>00266         u.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_n_ary_relation.html#ac963905a165f53a616f50d18b1635245">addOperand</a>(r);
<a name="l00267"></a>00267       }
<a name="l00268"></a>00268     }
<a name="l00269"></a>00269     <span class="keywordflow">if</span> (u.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_n_ary_relation.html#aed20a0eb0271434efde6557d9d1064f9">m_relations</a>.size() &lt; 2)
<a name="l00270"></a>00270       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Intersection of less than 2 relations&quot;</span>);
<a name="l00271"></a>00271     <span class="keywordflow">return</span> u;
<a name="l00272"></a>00272   }
<a name="l00273"></a>00273   
<a name="l00286"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a8e21a91121539f67a814efef10822db4">00286</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a8e21a91121539f67a814efef10822db4">parseProduct</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00287"></a>00287   {
<a name="l00288"></a>00288     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_product.html">Product</a> p = <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_product.html">Product</a>();
<a name="l00289"></a>00289     NodeList nl = e.getChildNodes();
<a name="l00290"></a>00290     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00291"></a>00291     {
<a name="l00292"></a>00292       Node n = nl.item(i);
<a name="l00293"></a>00293       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;operand&quot;</span>) == 0)
<a name="l00294"></a>00294       {
<a name="l00295"></a>00295         <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> r = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af45aba32674228c6538d7055ea6e0c6d">parse</a>(n);
<a name="l00296"></a>00296         p.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_n_ary_relation.html#ac963905a165f53a616f50d18b1635245">addOperand</a>(r);
<a name="l00297"></a>00297       }
<a name="l00298"></a>00298     }
<a name="l00299"></a>00299     <span class="keywordflow">if</span> (p.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_n_ary_relation.html#aed20a0eb0271434efde6557d9d1064f9">m_relations</a>.size() &lt; 2)
<a name="l00300"></a>00300       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Product of less than 2 relations&quot;</span>);
<a name="l00301"></a>00301     <span class="keywordflow">return</span> p;
<a name="l00302"></a>00302   }
<a name="l00303"></a>00303   
<a name="l00316"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a27d80682bbafcc426244da865b0746b6">00316</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a27d80682bbafcc426244da865b0746b6">parseJoin</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00317"></a>00317   {
<a name="l00318"></a>00318     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_join.html">Join</a> j = <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_join.html">Join</a>();
<a name="l00319"></a>00319     NodeList nl = e.getChildNodes();
<a name="l00320"></a>00320     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00321"></a>00321     {
<a name="l00322"></a>00322       Node n = nl.item(i);
<a name="l00323"></a>00323       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;operand&quot;</span>) == 0)
<a name="l00324"></a>00324       {
<a name="l00325"></a>00325         <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> r = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af45aba32674228c6538d7055ea6e0c6d">parse</a>(n);
<a name="l00326"></a>00326         <span class="keywordflow">if</span> (j.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_binary_relation.html#ab8fbe3c2accf815763831a48bae8064e">m_left</a> == null)
<a name="l00327"></a>00327           j.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_binary_relation.html#a323a338ef8c483b2631f63eede83e206">setLeft</a>(r);
<a name="l00328"></a>00328         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (j.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_binary_relation.html#adce5ff1bbed0598dd208fca87338a17e">m_right</a> == null)
<a name="l00329"></a>00329           j.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_binary_relation.html#a22750410220fe713832bb17c0b323e8f">setRight</a>(r);
<a name="l00330"></a>00330         <span class="keywordflow">else</span>
<a name="l00331"></a>00331           <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Join of more than 2 relations&quot;</span>);
<a name="l00332"></a>00332       }
<a name="l00333"></a>00333       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;condition&quot;</span>) == 0)
<a name="l00334"></a>00334       {
<a name="l00335"></a>00335         <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_condition.html">Condition</a> c = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a9159995fce11b75b9e42bf35dbb9ac8f">parseCondition</a>(n);
<a name="l00336"></a>00336         j.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_join.html#a8041227e2b346ccb7b9c67e45efc5802">m_condition</a> = c;
<a name="l00337"></a>00337       }
<a name="l00338"></a>00338     }
<a name="l00339"></a>00339     <span class="keywordflow">if</span> (j.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_binary_relation.html#ab8fbe3c2accf815763831a48bae8064e">m_left</a> == null || j.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_binary_relation.html#adce5ff1bbed0598dd208fca87338a17e">m_right</a> == null)
<a name="l00340"></a>00340       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Join of less than 2 relations&quot;</span>);
<a name="l00341"></a>00341     <span class="keywordflow">if</span> (j.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_join.html#a8041227e2b346ccb7b9c67e45efc5802">m_condition</a> == null)
<a name="l00342"></a>00342       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Join without a join condition&quot;</span>);
<a name="l00343"></a>00343     <span class="keywordflow">return</span> j;
<a name="l00344"></a>00344   }
<a name="l00345"></a>00345   
<a name="l00358"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a9159995fce11b75b9e42bf35dbb9ac8f">00358</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_condition.html">Condition</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a9159995fce11b75b9e42bf35dbb9ac8f">parseCondition</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00359"></a>00359   {
<a name="l00360"></a>00360     NodeList nl = e.getChildNodes();
<a name="l00361"></a>00361     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00362"></a>00362     {
<a name="l00363"></a>00363       Node n = nl.item(i);
<a name="l00364"></a>00364       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;equals&quot;</span>) == 0)
<a name="l00365"></a>00365       {
<a name="l00366"></a>00366         <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a56826856d4e7376518b1dfa3ec7cd5fa">parseEquality</a>(n);
<a name="l00367"></a>00367       }
<a name="l00368"></a>00368       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;and&quot;</span>) == 0)
<a name="l00369"></a>00369       {
<a name="l00370"></a>00370         <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a18a84cdd0f9b6fcb7326d4a7e33d6eb0">parseNAryCondition</a>(<span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_logical_and.html">LogicalAnd</a>(), n);
<a name="l00371"></a>00371       }
<a name="l00372"></a>00372       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;or&quot;</span>) == 0)
<a name="l00373"></a>00373       {
<a name="l00374"></a>00374         <span class="keywordflow">return</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a18a84cdd0f9b6fcb7326d4a7e33d6eb0">parseNAryCondition</a>(<span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_logical_or.html">LogicalOr</a>(), n);
<a name="l00375"></a>00375       }
<a name="l00376"></a>00376     }
<a name="l00377"></a>00377     <span class="comment">// If we get here, we did not recognize any condition we know</span>
<a name="l00378"></a>00378     <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;No condition recognized&quot;</span>);
<a name="l00379"></a>00379   }
<a name="l00380"></a>00380   
<a name="l00381"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a18a84cdd0f9b6fcb7326d4a7e33d6eb0">00381</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_condition.html">Condition</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a18a84cdd0f9b6fcb7326d4a7e33d6eb0">parseNAryCondition</a>(<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_n_ary_condition.html">NAryCondition</a> c, Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00382"></a>00382   {
<a name="l00383"></a>00383     NodeList nl = e.getChildNodes();
<a name="l00384"></a>00384     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00385"></a>00385     {
<a name="l00386"></a>00386       Node n = nl.item(i);
<a name="l00387"></a>00387       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;condition&quot;</span>) == 0)
<a name="l00388"></a>00388       {
<a name="l00389"></a>00389         <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_condition.html">Condition</a> c_in = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a9159995fce11b75b9e42bf35dbb9ac8f">parseCondition</a>(n);
<a name="l00390"></a>00390         c.addCondition(c_in);
<a name="l00391"></a>00391       }
<a name="l00392"></a>00392     }
<a name="l00393"></a>00393     <span class="keywordflow">return</span> c;
<a name="l00394"></a>00394   }
<a name="l00395"></a>00395   
<a name="l00409"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a56826856d4e7376518b1dfa3ec7cd5fa">00409</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_equality.html">Equality</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a56826856d4e7376518b1dfa3ec7cd5fa">parseEquality</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00410"></a>00410   {
<a name="l00411"></a>00411     NodeList nl = e.getChildNodes();
<a name="l00412"></a>00412     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_literal.html">Literal</a> left = null, right = null;
<a name="l00413"></a>00413     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00414"></a>00414     {
<a name="l00415"></a>00415       Node n = nl.item(i);
<a name="l00416"></a>00416       <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_literal.html">Literal</a> a = null;
<a name="l00417"></a>00417       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;attribute&quot;</span>) == 0)
<a name="l00418"></a>00418       {
<a name="l00419"></a>00419         a = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#ad748c6c41e3d4e80d06d51fac3bdce52">parseAttribute</a>(n);
<a name="l00420"></a>00420       }
<a name="l00421"></a>00421       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;value&quot;</span>) == 0)
<a name="l00422"></a>00422       {
<a name="l00423"></a>00423         a = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#ac06fc0f5edfc92be143e2d756e2a9391">parseValue</a>(n);
<a name="l00424"></a>00424       }
<a name="l00425"></a>00425       <span class="keywordflow">else</span>
<a name="l00426"></a>00426         <span class="keywordflow">continue</span>;
<a name="l00427"></a>00427       <span class="keywordflow">if</span> (left == null)
<a name="l00428"></a>00428         left = a;
<a name="l00429"></a>00429       <span class="keywordflow">else</span>
<a name="l00430"></a>00430         right = a;
<a name="l00431"></a>00431     }
<a name="l00432"></a>00432     <span class="keywordflow">if</span> (left == null || right == null)
<a name="l00433"></a>00433       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Missing operand in condition &#39;equals&#39;&quot;</span>);
<a name="l00434"></a>00434     <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_equality.html">Equality</a>(left, right);
<a name="l00435"></a>00435   }
<a name="l00436"></a>00436 
<a name="l00445"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#ad748c6c41e3d4e80d06d51fac3bdce52">00445</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html">Attribute</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#ad748c6c41e3d4e80d06d51fac3bdce52">parseAttribute</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00446"></a>00446   {
<a name="l00447"></a>00447     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html">Attribute</a> a = <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html">Attribute</a>();
<a name="l00448"></a>00448     NodeList nl = e.getChildNodes();
<a name="l00449"></a>00449     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00450"></a>00450     {
<a name="l00451"></a>00451       Node n = nl.item(i);
<a name="l00452"></a>00452       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;name&quot;</span>) == 0)
<a name="l00453"></a>00453       {
<a name="l00454"></a>00454         a.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#aaeb60bbc71fd9f4d88d984791a97d731">setName</a>(n.getTextContent().trim());
<a name="l00455"></a>00455       }
<a name="l00456"></a>00456       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;table&quot;</span>) == 0)
<a name="l00457"></a>00457       {
<a name="l00458"></a>00458         a.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a0571679249446044c28bb450c020c00c">setTableName</a>(n.getTextContent().trim());
<a name="l00459"></a>00459       }
<a name="l00460"></a>00460     }
<a name="l00461"></a>00461     <span class="keywordflow">if</span> (a.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html#a607a2ddb9db89ceab7d0201ccf4be3ba">getName</a>().isEmpty())
<a name="l00462"></a>00462       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Empty attribute name&quot;</span>);
<a name="l00463"></a>00463     <span class="keywordflow">return</span> a;
<a name="l00464"></a>00464   }
<a name="l00465"></a>00465   
<a name="l00474"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a7edd33f9f801afd27ef02f1fd780ffaa">00474</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_variable_table.html">VariableTable</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a7edd33f9f801afd27ef02f1fd780ffaa">parseVariableTable</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00475"></a>00475   {
<a name="l00476"></a>00476     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_variable_table.html">VariableTable</a> vt = <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_variable_table.html">VariableTable</a>();
<a name="l00477"></a>00477     NodeList nl = e.getChildNodes();
<a name="l00478"></a>00478     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00479"></a>00479     {
<a name="l00480"></a>00480       Node n = nl.item(i);
<a name="l00481"></a>00481       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;name&quot;</span>) == 0)
<a name="l00482"></a>00482       {
<a name="l00483"></a>00483         vt.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_variable_table.html#af96b675d3483a6332ee899f949fa9c22">setName</a>(n.getTextContent().trim());
<a name="l00484"></a>00484       }
<a name="l00485"></a>00485       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;site&quot;</span>) == 0)
<a name="l00486"></a>00486       {
<a name="l00487"></a>00487         vt.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_variable_table.html#a31000ab758c3230089cd00280d457cee">setSite</a>(n.getTextContent().trim());
<a name="l00488"></a>00488       }
<a name="l00489"></a>00489       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;operand&quot;</span>) == 0)
<a name="l00490"></a>00490       {
<a name="l00491"></a>00491         <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_relation.html">Relation</a> r = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#af45aba32674228c6538d7055ea6e0c6d">parse</a>(n);
<a name="l00492"></a>00492         vt.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_unary_relation.html#a4e8c1751811a5c45c6d4ebf611146b3d">setRelation</a>(r);
<a name="l00493"></a>00493       }
<a name="l00494"></a>00494     }
<a name="l00495"></a>00495     <span class="keywordflow">if</span> (vt.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_variable_table.html#a3a7352abd5bca8b9904a80b1a1b9bdfc">getName</a>().isEmpty())
<a name="l00496"></a>00496       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Empty vartable name&quot;</span>);
<a name="l00497"></a>00497     <span class="keywordflow">return</span> vt;
<a name="l00498"></a>00498   }
<a name="l00499"></a>00499   
<a name="l00508"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a309204e090ef3db07832361e1d986668">00508</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_table.html">Table</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a309204e090ef3db07832361e1d986668">parseTable</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00509"></a>00509   {
<a name="l00510"></a>00510     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_schema.html">Schema</a> s = null;
<a name="l00511"></a>00511     String table_name = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00512"></a>00512     List&lt;Tuple&gt; tuples = <span class="keyword">new</span> LinkedList&lt;Tuple&gt;();
<a name="l00513"></a>00513     NodeList nl = e.getChildNodes();
<a name="l00514"></a>00514     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00515"></a>00515     {
<a name="l00516"></a>00516       Node n = nl.item(i);
<a name="l00517"></a>00517       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;schema&quot;</span>) == 0)
<a name="l00518"></a>00518       {
<a name="l00519"></a>00519         s = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a7d8c7b2bd4e9d833c98231d5ec43a656">parseSchema</a>(n);
<a name="l00520"></a>00520       }
<a name="l00521"></a>00521       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;name&quot;</span>) == 0)
<a name="l00522"></a>00522       {
<a name="l00523"></a>00523         table_name = n.getTextContent().trim();
<a name="l00524"></a>00524       }
<a name="l00525"></a>00525       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;tuple&quot;</span>) == 0)
<a name="l00526"></a>00526       {
<a name="l00527"></a>00527         <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_tuple.html">Tuple</a> t = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#adf09201d21e9053af2a76a608285dc41">parseTuple</a>(n);
<a name="l00528"></a>00528         tuples.add(t);
<a name="l00529"></a>00529       }
<a name="l00530"></a>00530     }
<a name="l00531"></a>00531     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_table.html">Table</a> tab = <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_table.html">Table</a>(table_name);
<a name="l00532"></a>00532     tab.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_table.html#a226e2304771b71716a8961a4a0a8446e">setSchema</a>(s);
<a name="l00533"></a>00533     tab.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_table.html#a6d4c40243f777b5cb535b5b2435e24c3">putAll</a>(tuples);
<a name="l00534"></a>00534     <span class="keywordflow">if</span> (s == null)
<a name="l00535"></a>00535       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Missing schema in projection&quot;</span>);
<a name="l00536"></a>00536     <span class="keywordflow">return</span> tab;
<a name="l00537"></a>00537   }
<a name="l00538"></a>00538   
<a name="l00547"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#ac06fc0f5edfc92be143e2d756e2a9391">00547</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_value.html">Value</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#ac06fc0f5edfc92be143e2d756e2a9391">parseValue</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00548"></a>00548   {
<a name="l00549"></a>00549     NodeList nl = e.getChildNodes();
<a name="l00550"></a>00550     <span class="keywordflow">if</span> (nl.getLength() == 0)
<a name="l00551"></a>00551       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Empty value&quot;</span>);
<a name="l00552"></a>00552     Node n = nl.item(0);
<a name="l00553"></a>00553     <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_value.html">Value</a>(n.getTextContent().trim());
<a name="l00554"></a>00554   }
<a name="l00555"></a>00555   
<a name="l00568"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#adf09201d21e9053af2a76a608285dc41">00568</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_tuple.html">Tuple</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#adf09201d21e9053af2a76a608285dc41">parseTuple</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00569"></a>00569   {
<a name="l00570"></a>00570     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_tuple.html">Tuple</a> t = <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_tuple.html">Tuple</a>();
<a name="l00571"></a>00571     NodeList nl = e.getChildNodes();
<a name="l00572"></a>00572     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00573"></a>00573     {
<a name="l00574"></a>00574       Node n = nl.item(i);
<a name="l00575"></a>00575       <span class="keywordflow">if</span> (n.getNodeType() == Node.ELEMENT_NODE)
<a name="l00576"></a>00576       {
<a name="l00577"></a>00577         String name = n.getNodeName();
<a name="l00578"></a>00578         String value = n.getTextContent().trim();
<a name="l00579"></a>00579         t.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_tuple.html#a55688bd4a73cc7b161b0169cbd214eea">put</a>(<span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html">Attribute</a>(name), <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_value.html">Value</a>(value));
<a name="l00580"></a>00580       }
<a name="l00581"></a>00581     }
<a name="l00582"></a>00582     <span class="keywordflow">if</span> (t.<a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_tuple.html#aa20fa8a28c37cb86d0b422ce8db63a0b">size</a>() == 0)
<a name="l00583"></a>00583       <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException(<span class="stringliteral">&quot;Empty tuple&quot;</span>);
<a name="l00584"></a>00584     <span class="keywordflow">return</span> t;
<a name="l00585"></a>00585   }
<a name="l00586"></a>00586 
<a name="l00599"></a><a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a7d8c7b2bd4e9d833c98231d5ec43a656">00599</a>   <span class="keyword">protected</span> <span class="keyword">static</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_schema.html">Schema</a> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#a7d8c7b2bd4e9d833c98231d5ec43a656">parseSchema</a>(Node e) <span class="keywordflow">throws</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html">XmlQueryParser</a>.ParseException
<a name="l00600"></a>00600   {
<a name="l00601"></a>00601     NodeList nl = e.getChildNodes();
<a name="l00602"></a>00602     <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_schema.html">Schema</a> s = <span class="keyword">new</span> <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_schema.html">Schema</a>();
<a name="l00603"></a>00603     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; nl.getLength(); i++)
<a name="l00604"></a>00604     {
<a name="l00605"></a>00605       Node n = nl.item(i);
<a name="l00606"></a>00606       <span class="keywordflow">if</span> (n.getNodeName().compareToIgnoreCase(<span class="stringliteral">&quot;attribute&quot;</span>) == 0)
<a name="l00607"></a>00607       {
<a name="l00608"></a>00608         <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_attribute.html">Attribute</a> a = <a class="code" href="classca_1_1uqac_1_1dim_1_1turtledb_1_1_xml_query_parser.html#ad748c6c41e3d4e80d06d51fac3bdce52">parseAttribute</a>(n);
<a name="l00609"></a>00609         s.add(a);
<a name="l00610"></a>00610       }
<a name="l00611"></a>00611     }
<a name="l00612"></a>00612     <span class="keywordflow">if</span> (s.size() == 0)
<a name="l00613"></a>00613       <span class="keywordflow">throw</span> <span class="keyword">new</span> ParseException(<span class="stringliteral">&quot;Empty schema&quot;</span>);
<a name="l00614"></a>00614     <span class="keywordflow">return</span> s;
<a name="l00615"></a>00615   }
<a name="l00616"></a>00616   
<a name="l00621"></a>00621   <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">class </span>ParseException <span class="keyword">extends</span> Exception
<a name="l00622"></a>00622   {
<a name="l00623"></a>00623     <span class="keyword">protected</span> String m_message = <span class="stringliteral">&quot;ParseException&quot;</span>;
<a name="l00624"></a>00624     <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keywordtype">long</span> serialVersionUID = 1L;
<a name="l00625"></a>00625     
<a name="l00626"></a>00626     <span class="keyword">public</span> ParseException(String msg)
<a name="l00627"></a>00627     {
<a name="l00628"></a>00628       m_message = msg;
<a name="l00629"></a>00629     }
<a name="l00630"></a>00630     
<a name="l00631"></a>00631     @Override
<a name="l00632"></a>00632     <span class="keyword">public</span> String toString()
<a name="l00633"></a>00633     {
<a name="l00634"></a>00634       <span class="keywordflow">return</span> m_message;
<a name="l00635"></a>00635     }
<a name="l00636"></a>00636   }
<a name="l00637"></a>00637 }
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_xml_query_parser_8java.html">XmlQueryParser.java</a>      </li>

    <li class="footer">Generated on Fri Dec 7 2012 18:55:40 for TurtleDB by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
